<?php
$block_data = $this->getBlockData();
$blocks = $block_data['block'];
$banners = $block_data['banners'];
$click_url = $this->getUrl('bannerslider/index/click');
?>

<script type="text/javascript" src="<?php echo $this->getJsUrl('magestore/bannerslider/jquery-1.7.min.js') ?>"></script>
<script type="text/javascript" src="<?php echo $this->getJsUrl('magestore/bannerslider/jquery.flexslider.js') ?>"></script>
<link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('css/magestore/bannerslider/flexslider.css') ?>" media="all" />
<script type="text/javascript">    
    // Can also be used with $(document).ready()
    var j8 = jQuery.noConflict();
    j8(window).load(function() {
        j8('.flexslider-8-<?php echo $blocks['bannerslider_id'] ?>').flexslider({
            animation: "<?php echo $blocks['animationB'];?>",
            controlNav: "thumbnails",  
            slideshowSpeed: <?php echo $blocks['slider_speed'];?>,
            minItems: <?php echo $this->getMinItem($blocks['min_item']); ?>,
            maxItems: <?php echo $this->getMaxItem($blocks['max_item']); ?>
        });
    });
</script>
<div class="flexslider flexslider-8-<?php echo $blocks['bannerslider_id'] ?>">
   <ul class="slides"> 
    <?php foreach ($banners as $banner): ?>
            <li  data-thumb="<?php echo $this->getBannerImage($banner['image']); ?>">
                <a href="<?php echo $banner['click_url']?>" target="<?php echo $this->getTarget($banner['tartget'])?>" onclick="bannerClicks('<?php echo $banner['banner_id'] ?>','<?php echo $blocks['bannerslider_id'] ?>')" style="display:block"><img alt="<?php echo $banner['image_alt'];?>" src="<?php echo $this->getBannerImage($banner['image']); ?>"/></a>
            </li>
    <?php endforeach; ?>            
    </ul>
</div>

<script type="text/javascript">
        function bannerClicks(id_banner, id_slider){
		click_url = '<?php echo $click_url;?>';
		banner_id = id_banner;
		new Ajax.Request(click_url,{
			method: 'post',
			parameters:{id_banner: banner_id, slider_id:id_slider},
			onFailure: '',
			onSuccess: ''
			
		});
		
	}
    </script>